﻿@model TruckingApplication.Dal.EntityModels.RESOURCE

@{
    ViewBag.Title = "Details";
}

<div id="lowerContainer">
	<div id="lowerContainerInner">
		<fieldset>
            <table id="tableMgmt" style="width: 100%;">
        <tr>
            <td>
                <div class="display-label">First Name</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.firstName)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Last Name</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.lastName)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Address</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.address)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">City</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.city)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">State</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.state)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Zip</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.zip)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Start Date</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.startDate)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">SS Num</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.ssNum)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Tax ID</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.taxID)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Email</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.email)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Phone</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.phone)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Commission</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.commission)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Resource Type</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.RESOURCE_TYPE.resourceType)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">MC Number</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.mcNumber)
            </td>
        </tr>
        <tr>
            <td>
                <div class="display-label">Factoring Fee</div>
            </td>
            <td colspan="3">
                    @Html.DisplayFor(model => model.factoringFee)
            </td>
        </tr>
        @{
            if (Model.TRAILERs != null)
            {
                foreach (TruckingApplication.Dal.EntityModels.TRAILER trailer in Model.TRAILERs)
                { 
                    <tr>
                        <th colspan="4" style="border-top:2px solid #Blue;"><h3>Trailer Information</h3></th>
                        </tr>
                        <tr>
                        <th style="border-top:2px solid #000;">Trailer Type</th>
                        <th style="border-top:2px solid #000;">Vin #</th>
                        <th style="border-top:2px solid #000;">Mileage</th>
                        <th></th>
                        </tr>
                        <tr>
                        <td>
                            @trailer.TRAILER_TYPE.type
                        </td>
                        <td>
                            @trailer.vin
                        </td>
                        <td>
                            @trailer.mileage
                        </td>
                    </tr>
            
                       if (trailer.TRAILER_LOG != null)
                       {
                           if (trailer.TRAILER_LOG.Count > 0)
                           {
                               var count = 0;
                               foreach (TruckingApplication.Dal.EntityModels.TRAILER_LOG log in trailer.TRAILER_LOG)
                               {
                                <tr>
                                    if(count == 0){
                                        <th colspan="4" style="border-top:2px solid #Blue;"><h3>Trailer Log</h3></th>
                                        </tr>
                                        <tr>
                                        <th style="border-top:2px solid #Blue;">Date</th>
                                        <th style="border-top:2px solid #Blue;">Previous Mileage</th>
                                        <th style="border-top:2px solid #Blue;" colspan="2">Current Mileage</th>
                                        </tr>
                                        <tr>
                                    }
                                    <td>@log.LOG.logDate.ToString()</td>
                                    <td>@log.LOG.previousMileage.ToString()</td>
                                    <td colspan="2">@log.LOG.currentMileage.ToString()</td>
                                </tr>
                                   count++;
                               }
                           }
                       }

                       if (trailer.ROADSIDE_ASSISTANCE != null)
                       {
                           List<TruckingApplication.Dal.EntityModels.ROADSIDE_ASSISTANCE> roadsides = trailer.ROADSIDE_ASSISTANCE.ToList();

                           foreach (TruckingApplication.Dal.EntityModels.ROADSIDE_ASSISTANCE roadside in roadsides)
                           { 
                                <tr>
                                    <th colspan="4" style="border-top:2px solid #Blue;"><h3>Roadside Assistance Information</h3></th>
                                    </tr>
                                    <tr>
                                    <th style="border-top:2px solid #Blue;">Start Date</th>
                                    <th style="border-top:2px solid #Blue;">End Date</th>
                                    <th style="border-top:2px solid #Blue;">Payment Terms</th>
                                    <th style="border-top:2px solid #Blue;">Payment Amount</th>
                                    </tr><tr>
                                    <td>
                                        @roadside.startDate
                                    </td>
                                    <td>
                                        @roadside.endDate
                                    </td>
                                    <td>
                                        @roadside.paymentTerms
                                    </td>
                                    <td>
                                        @roadside.paymentAmount
                                    </td>
                                </tr>
                            }
                       }

                       if (trailer.INSURANCEs != null)
                       {

                           List<TruckingApplication.Dal.EntityModels.INSURANCE> insurances = trailer.INSURANCEs.ToList();
                           
                           foreach (TruckingApplication.Dal.EntityModels.INSURANCE insurance in insurances)
                           { 
                                <tr>
                                    <th colspan="4" style="border-top:2px solid #Blue;"><h3>Insurance Information</h3></th>
                                    </tr>
                                    <tr>
                                    <th style="border-top:2px solid #Blue;">Start Date</th>
                                    <th style="border-top:2px solid #Blue;">End Date</th>
                                    <th style="border-top:2px solid #Blue;">Payment Terms</th>
                                    <th style="border-top:2px solid #Blue;">Payment Amount</th>
                                    </tr><tr>
                                    <td>
                                        @insurance.startDate
                                    </td>
                                    <td>
                                        @insurance.endDate
                                    </td>
                                    <td>
                                        @insurance.paymentTerms
                                    </td>
                                    <td>
                                        @insurance.paymentAmount
                                    </td>
                                </tr>
                            }
                       }
                }
            }
        }
            
        
        <tr>
            <td colspan="4">
                @Html.ActionLink("Edit", "Edit", new { id = Model.resourceID }, new { @class = "button default btnLarge" })
                @Html.ActionLink("Cancel", "Dashboard", "Account", null, new { @class = "button cancel btnLarge" })
            </td>
        </tr>
        
    </table>
        </fieldset>
   </div>
 </div>